﻿<%@ WebHandler Language="C#" Class="Login" %>

using System;
using System.Web;
using System.Web.SessionState;
using System.Collections.Generic;
using VBDWebMobile;

public class Login : IHttpHandler, IReadOnlySessionState{
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        string sReult = "{Result: false}";
        try
        {
            string sparam = context.Request.QueryString[0];
            Dictionary<string, string> value = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(sparam);
            VBDWebMobile.Users users = new Users();
            if (users.CheckUser(value["Name"], value["PW"]))
            {
                HttpContext.Current.Session["User"] = value["Name"];
                sReult = "{Result: true}";
                
            }

        }
        catch (Exception)
        {

            sReult = "{Result: false}";
        }

        context.Response.Write(Newtonsoft.Json.JsonConvert.DeserializeObject(sReult));
       
       
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}